#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int g_val=123;
int main()
{
    printf("There is a parent process running, pid:%d,ppid:%d,g_val:%d,&g_val:%p\n",getpid(),getppid(),g_val,&g_val);
    pid_t id=fork();
    if(id==0)
    {
        int cnt=5;
        while(1)
        {
            printf("I am am child process, pid:%d,ppid:%d,g_val:%d,&g_val:%p\n",getpid(),getppid(),g_val,&g_val);
            sleep(1);
            cnt--;
            if(cnt==0)
            {
                g_val=345;
                printf("g_val is changed : 123 -> %d \n",g_val);
            }
        }
    }
    else{
        while(1)
        {
            printf("I am am parent process, pid:%d,ppid:%d,g_val:%d,&g_val:%p\n",getpid(),getppid(),g_val,&g_val);
            sleep(1);
        }
    }
    return 0;
}
